<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title> Item </title>
    <style>
        .active{
            color: red;
        }
        .box1{
            width: 500px;
            height: 500px;
            border: 1px solid red;
        }
        .box2{
            width: 400px;
            height: 400px;
            border: 1px solid blue;
        }
        .box3{
            width: 300px;
            height: 300px;
            border: 1px solid green;
        }
        .box4{
            width: 200px;
            height: 200px;
            border: 1px solid yellow;
        }
        .box5{
            width: 100px;
            height: 100px;
            border: 1px solid rgb(245, 26, 197);
        }
    </style>
</head>
<body>
    <div>
        <ul class="list">
            <li>item1</li>
            <li>item2</li>
            <li>item3</li>
            <li>item4</li>
            <li>item5</li>
        </ul>
    </div>
    <div class="box1">
        <div class="box2">
            <div class="box3">
                <div class="box4">
                    <div class="box5">

                    </div>
                </div>
            </div>
        </div>
    </div>
    
</body>
<script src="../lib/jquery.min.js"></script>
<script>
    $(function(){
        //为每一个li标签都添加事件监听
        //事件委派
        $(".list").click(function(e){
            $(e.target).addClass('active').siblings().removeClass('active');

            
        })







        // $('.list li').click(function(){
        //     //排他效果
        //     //siblings  next 查找同类
        //     $(this).addClass('active').siblings().removeClass('active');

        // });

        // parent parents 查找父类
        // $(".box5").click(function(){
        //     $(this).parents('.box2').css('border','5px solid red');
        // })

        //find  children  查找子类
        $(".box1").click(function(){
            // $(this).children().css('border','2px solid red');
            $(this).find('.box5').css('border','2px solid red');

        })
        
    });
</script>
</html>